<button class="btn btn-primary" type="button" onclick="addSomain()">新增</button>

<table class="table" id="pomainDiv">
    <thead>
    <tr>
        <th>序号</th>
        <th>销售单编号</th>
        <th>创建时间</th>
        <th>客户名称</th>
        <th>创建用户</th>
        <th>附加费用</th>
        <th>销售商品总价</th>
        <th>销售单总价</th>
        <th>付款方式</th>
        <th>最低预付款金额</th>
        <th colspan="3">操作</th>
    </tr>
    </thead>
    <tbody id="tableBody"></tbody>
</table>
<div>
    <ul id="page">分页</ul>
</div>

<script id="somainListTemplate" type="text/html">
    {{each data value index}}
    <tr>
        <td>{{index+1}}</td>
        <td>{{value.soId}}</td>
        <td>{{value.createTime}}</td>
        <td>{{value.customerList[0].name}}</td>
        <td>{{value.scmUserList[0].name}}</td>
        <td>{{value.tipFee}}</td>
        <td>{{value.productTotal}}</td>
        <td>{{value.soTotal}}</td>
        <td>{{value.payType}}</td>
        <td>{{value.prePayFee}}</td>
        <td><input value="删除" type="button"  onclick="return del('{{value.soId}}')"></td>
        <td><input value="修改" type="button"  onclick="update('{{value.soId}}')"></td>
        <td><input value="查看明细" type="button"  onclick="searchSo('{{value.soId}}')"></td>
    </tr>
    {{/each}}
</script>

<script>
    $(function () {
        showPage({
            currentPage: 1,
            pageSize: 5,
            url: '/getAllSomain',
            templateId: 'somainListTemplate',
            contentId: 'tableBody',
            params: {
                id: 1
            }
        })
    })
    function del(obj) {
        if(confirm("确认删除？")){
            Ajax.post(
                "/deleteSomain",
                {soId:obj},
                function (result) {
                    show('so/somain.html')
                    alert(result.msg)
                }
            )
        }else{
            show('so/somain.html')
            return false;
        }

    }
    function update(obj) {
        window.sessionStorage.setItem("soId",obj)
        show("/so/somainUpdate.html")
    }
</script>
